﻿using System.Collections.Generic;
using System.Reflection;

namespace XamlInspector.Model.Properties
{
    public class XamlCompositeProperty : XamlProperty
    {
        private readonly PropertyInfo _propertyInfo;
        private readonly object _element;
        private List<XamlProperty> _properties;

        public XamlCompositeProperty(PropertyInfo propertyInfo, object element) 
            : base(propertyInfo, element)
        {
            _propertyInfo = propertyInfo;
            _element = element;
        }

        public List<XamlProperty> Properties
        {
            get
            {
                if (_properties == null)
                {
                    _properties = new List<XamlProperty>(PropertyHelper.GetProperties(_element, _propertyInfo.Name));
                }

                return _properties;
            }
        }
    }
}
